Use case: Memory initialization using XSPIM configuration ¶
Memory initialization using XSPIM configuration.
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
OSPI_HandleTypeDef ospi;
OSPIM_CfgTypeDef sOspiManagerCfg = {0};
sOspiManagerCfg.nCSOverride = HAL_OSPI_CSSEL_OVR_NCS1;
sOspiManagerCfg.IOPort = HAL_OSPIM_IOPORT_1;
HAL_OSPIM_Config(&ospi, &sOspiManagerCfg, OSPI_TIMEOUT);
ospi.Instance = OSPI;
ospi.Init.FifoThresholdByte = 4;
ospi.Init.MemoryMode = HAL_OSPI_SINGLE_MEM;
ospi.Init.MemoryType = HAL_OSPI_MEMTYPE_APMEM_16BITS;
ospi.Init.MemorySize = HAL_OSPI_SIZE_256MB;
ospi.Init.ChipSelectHighTimeCycle = 5;
ospi.Init.FreeRunningClock = HAL_OSPI_FREERUNCLK_DISABLE;
ospi.Init.ClockMode = HAL_OSPI_CLOCK_MODE_0;
ospi.Init.WrapSize = HAL_OSPI_WRAP_NOT_SUPPORTED;
ospi.Init.ClockPrescaler = 0;
ospi.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFT_NONE;
ospi.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_DISABLE;
ospi.Init.ChipSelectBoundary = HAL_OSPI_BONDARYOF_8KB;
ospi.Init.MaxTran = 0;
ospi.Init.Refresh = 0;
ospi.Init.MemorySelect = HAL_OSPI_CSSEL_NCS1;
HAL_OSPI_Init(&ospi);
|
hal_xspi_handle_t xspi;
hal_xspi_xspim_config_t sOspiManagerCfg;
sOspiManagerCfg.port1.clk = HAL_XSPI_XSPIM_XSPI1;
sOspiManagerCfg.port1.dqs = HAL_XSPI_XSPIM_XSPI1;
sOspiManagerCfg.port1.ncs = HAL_XSPI_XSPIM_XSPI1;
sOspiManagerCfg.port1.io_low = HAL_XSPI_XSPIM_XSPI1_IO_LOW;
sOspiManagerCfg.port1.io_high = HAL_XSPI_XSPIM_XSPI1_IO_HIGH;
sOspiManagerCfg.req_ack_cycle = 1U;
HAL_XSPI_XSPIM_SetConfig(&sOspiManagerCfg);
HAL_XSPI_Init(&xspi, HAL_OCTOSPI1);
hal_xspi_config_t HAL_XSPI_Global_Cfg_Struct;
HAL_XSPI_Global_Cfg_Struct.memory = HAL_XSPI_Mem_Cfg_Struct;
HAL_XSPI_Global_Cfg_Struct.timing = HAL_XSPI_Timing_Cfg_Struct;
HAL_XSPI_SetConfig(&xspi, &HAL_XSPI_Global_Cfg_Struct);
|
Key changes ¶
In HAL2, OSPIM configuration is performed through XSPI XSPIM configuration (for example,
HAL_OSPIM_Config()becomesHAL_XSPI_XSPIM_SetConfig()).In HAL2, OSPI initialization and configuration are replaced by
HAL_XSPI_Init()andHAL_XSPI_SetConfig().

